<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/lib/angular.min.js"></script>	
		<link rel="stylesheet" href="css/lib/bootstrap.min.css" />
		<link rel="stylesheet" href="js/themes/default/easyui.css" />
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>	
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<style>
		body{
			font-size:12px;
		}
		table,
		/* th,
		td {
			border: 1px solid grey;
			border-collapse: collapse;
			padding: 5px;
			vertical-align: middle !important;
		} */
		
		/* table td:nth-child(odd) {
			background-color: #f1f1f1;#e2e9ea
			
		} */
		table td:nth-child(even) {
			
		}
		/* table tr:nth-child(even) {
			background-color:#ffffff;
		} */
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:center;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: center;
			font-size:30px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}
	</style>
	<body ng-app="myApp" ng-controller="customersCtrl">
		<div class="">
			<div id="sho"></div>
		<!--第三个查询请求-->
		<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover" style="width:50%;">				
					<tr>
						<th style="font-size:30px;" colspan="6">查看用户各通道刷卡费率</th>
					</tr>
					<tr style="font-size:15px;">
						<!-- <td style="width:45px;" class="text-center">序号</td> -->
						<!-- <td class="text-center">通道编号</td> -->
						<td class="text-center">通道名称</td>
						<td class="text-center">刷卡费率</td>
						<!-- <td class="text-center">T0+T1</td> -->
						<td class="text-center">单笔最小金额</td>
						<td class="text-center">单笔最大金额</td>
						<td class="text-center">当天最大金额</td>
						
						<!-- <td class="text-center">修改</td> -->
						<!-- <td class="text-center">结束时间</td> -->
					</tr>
					<tr ng-repeat="item in items2" ng-show ="item.channelNo==2 || item.channelNo==1">
						<!-- <td class="text-center">#{{$index+1}}</td> -->
						<!-- <td class="text-center">{{item.id}}</td> -->
						<td class="text-left" style="width:20%"><img style="width:25px;height:25px;margin:0 10px 0 10px" src="{{item.log}}" alt="log">{{item.name}}-{{item.channelParams}}</td>
						<td class="text-center">{{item.rate}}/每万{{(item.rate*10000).toFixed(0)}}元
						<!-- <td class="text-center">{{item.channelParams}}</td> -->
						<td class="text-center">￥{{item.singleMinLimit}}</td>
						<td class="text-center">￥{{item.singleMaxLimit}}</td>
						<td class="text-center">￥{{item.everyDayMaxLimit}}</td>
						
							
						<!-- <td class="text-center"><button class="btn btn-default" ng-click="add(item)">修改费率</button></td> -->
						<!-- <td class="text-center">{{item.createTime}}</td> -->
					</tr>
					<tr>
						<td colspan="6" id="show02" class="text-center" style="display:none;">
						</td>
					</tr>				
			</table>		
		</div>
		</div>
	</body>
	<script>		
		$(function(){
			var userid = sessionStorage.getItem(key=13); 
			$('#f1').val(userid);
			$('#f2').change(function(){
				var f1 = $("#f1").val();
				var f2 = $('#f2').val();
				console.log($("#f1").val())
				console.log($("#f2").val())
				$.ajax({
					url:window.baseUrl+"user/channel/rate/query/userid",
					type:"POST",
					dataType:"json",
					data:{
						user_id:f1,
						channel_id:f2,
					},
					success:function(data){
						console.log("开始远程调用...")
						console.log(data.result)
						$('#f3').val(data.result.rate)
						$('#f4').html(data.result.withdrawFee+"元")
					},
					error:function(){
						console.log("调用失败！");
						$('#show').hide();
						$('#show01').show().html("暂无数据");
					}
				})				
			});
			/*修改用户的通道费率:*/
            $('#f3').on('keyup',function(){
                var v = parseInt($('#f3').val()*10000);
                console.log(v);
                if(v>52){
                    $('#f3').val(0.0052)
				}
            });
			$('#f3').on('blur',function(){
				var v= $('#f3').val();
				if(v<0.0035){
				    alert('您的费率设置有误！请认真核对')
				    $('#f3').val(0.0035)
				}
			});

			$("#query1").click(function(){
				var f1 = $('#f1').val();
				var f2 = $('#f2').val();
				var f3 = $('#f3').val();
				console.log(f1);
				console.log(f2);
				console.log(f3);
				$.ajax({
					url:window.baseUrl+"user/channel/rate/update/userid",
					type:"POST",
					dataType:"json",
					data:{
						user_id:f1,
						channel_id:f2,
						rate:f3
					},
					success:function(data){
						console.log("开始远程调用...");
						console.log(data.result);
						var msg = data.result;
						if(data.result == null){
							$('#show').hide();
							$("#show01").show().html("暂无数据...")							
						}else{
							alert('成功设置费率为'+msg.rate);
							window.location.href = "zy03.html";
							$('#show01').hide();
							$('#show').show();
							$('#show1').html(msg.userId);
							$('#show2').html(msg.brandId);
							$('#show3').html(msg.channelId);
							if(msg.extraFee==null){
								$('#show4').html("-")
							}else{
								$('#show4').html(msg.extraFee)
							};							
							$('#show5').html("￥"+msg.withdrawFee);
							$('#show6').html(msg.rate+"%");
							$('#show7').html(msg.createTime);
						}											
					},
					error:function(){
						console.log("调用失败！");
						$('#show').hide();
						$('#show01').show().html("暂无数据");
					}
				})
			})
		})
	</script>
	<script>
		var app = angular.module('myApp', []);
		/*自定义过滤器   1*/
				app.filter('modify0',function(){
					return function(input,param){
						if(param == "WEIXIN_QRCODE"){
							return param = "微信支付"
						}
						if(param == "ALIPAY_QRCODE"){
							return param = "支付宝支付"
						}
						if(param == "YILIAN"){
							return param = "易联支付"
						}
						if(param == "ZHONGMAO_PAY"){
							return param = "中贸支付"
						}
						if(param == "JIEFUBAO"){
							return param = "京东钱包"
						}
						if(param == "SWIFT_QQ_QRCODE"){
							return param = "qq扫码"
						}
						if(param == "SWIFT_ALIPAY_QRCODE"){
							return param = "支付宝扫码"
						}
						if(param == "SWIFT_WEIXIN_QRCODE"){
							return param = "微信扫码支付"
						}
					}
				});

	        app.controller('customersCtrl', function($scope, $http ){
	        	var userid = sessionStorage.getItem(key=13); 
				$('#f1').val(userid);
				/*根据用户编号展示所有平台信息和费率*/
				$http({
					method: 'POST',
					params: {user_id:userid},
					url: window.baseUrl+'user/channel/query/all/brandid'
				}).then(function successCallback(data){
						console.log("请求数据成功...");
						console.log(data.data.result);
						$scope.items2 = data.data.result
				}, function errorCallback(data) {
						console.log("请求数据失败...");
				     	console.log(data)
				});
				/*修改用户刷卡费率*/
				$scope.add = function(item){                   
				    console.log(item);
                    var userid = sessionStorage.getItem(key=13);
					var id = item.id;
					var rate = item.rate;
					console.log(userid);
				    console.log(id);
				    console.log(rate);
                    $http({
                        method: 'POST',
                        params: {
                            user_id:userid,
                            channel_id:id,
                            rate:rate
                        },
                        url: window.baseUrl+'user/channel/rate/update/userid'
                    }).then(function successCallback(data){
                        console.log("修改数据成功...");
                        console.log(data.data.result);
                        if(data.data.resp_code == 000000)
                        alert("成功设置【"+item.name+item.channelParams+"】通道刷卡费率为"+item.rate);
						if(data.data.resp_code == 999999)
						alert(data.data.resp_message);	

                    }, function errorCallback(data) {
                        console.log("修改数据失败...");
                        console.log(data)
                    })
                }
			});
	</script>
</html>




